// StraightShooter.cpp //
#include "StraightShooter.h"

#include "Player.h"
#include "Bullet.h"

//bad guy that moves straight down and shoots straight down

StraightShooter::StraightShooter(string keyname) : Enemy(keyname)
{
	pointValue = StraightShooterPointValue;
	health = StraightShooterHealth;
	speed = StraightShooterSpeed;
	lastFired = 0.0f;
}

void StraightShooter::Update(float deltaTime)
{
	if(this->numValue == -1)
		this->TakeDamage(this->health);
	Enemy::Update(deltaTime);
	lastFired += deltaTime;
	if(lastFired > StraightShooterFireDelay)
	    FireBullet();
}

//fires bullet straight down
void StraightShooter::FireBullet()
{
	Bullet* bullet = new Bullet("Mite");
	bullet->health = 30;
    bullet->position = position + Vector(0, 58.0f);
    bullet->direction = Vector(0, 1);
    bullet->CollisionList = &PlayerShip::PlayerShipList;

    lastFired = 0.0f;
}

//renders with non cenetered number and colored text
void StraightShooter::Render(SDL_Surface* screen)
{
	char buffer[4];
	sprintf(buffer, "%d", this->numValue);
	sprite->Render(screen,position);
	sprite->texture->DrawText(screen,buffer,16,this->position.X,this->position.Y+35,160,20,20,true);
}
